package com.zhl.spark.core.simple.complex

import java.io.ObjectOutputStream
import java.net.Socket

/**
 * @program: demos
 * @description: ${description}
 * @author: 刘振华
 * @create: 2020-11-30 17:42
 **/
object PlexDriver {
    def main(args: Array[String]): Unit = {
        val pTask = new PlexAllTask()

        val task1 = new PlexTask()
        task1.datas = pTask.datas.take(2)
        task1.logic = pTask.logic
        send(19991,task1)

        val task2 = new PlexTask()
        task2.datas = pTask.datas.takeRight(2)
        task2.logic = pTask.logic

        send(19992,task2)


    }

    def send(port:Int,task: PlexTask)={
        val socket = new Socket("localhost", port)

        val out = socket.getOutputStream()

        val objOut = new ObjectOutputStream(out)

        objOut.writeObject(task)

        objOut.flush()
        objOut.close()
        socket.close()
    }
}
